const Koa = require("koa");
const Router = require("koa-router");
const views = require("koa-views");
const path = require("path");

const app = new Koa();
const router = new Router();

app.use(
  views(path.resolve(__dirname, "template"), {
    extension: "pug"
  })
);

router.get("/", async ctx => {
  await ctx.render("index", {
    title: "网易林灿灿", // 向页面传参
    list: [
      { name: "林灿灿", age: 16 },
      { name: "开心", age: 17 }
    ]
  });
});
// router.get("/", ctx => {
//   ctx.body = "主页";
// });

app.use(router.routes());
app.listen(3000);
